from fastapi import APIRouter, status

from app.crud.studies import (
    create_medical_study,
    delete_medical_study,
    get_all_medical_studies,
    update_medical_study,
)
from app.models.studies import EnhancementType
from app.schemas.studies import (
    MedicalStudyCreateSchema,
    MedicalStudySchema,
    MedicalStudyUpdateSchema,
)

router = APIRouter()


@router.get("/enhancement-types/", response_model=list[str])
async def get_enhancement_types_():
    """Get all enhancement types"""
    return [enhancement_type.value for enhancement_type in EnhancementType]


@router.post("/", response_model=MedicalStudySchema, status_code=status.HTTP_201_CREATED)
async def create_medical_study_(medical_study_schema: MedicalStudyCreateSchema):
    """Create a new medical study"""
    return await create_medical_study(medical_study_schema)


@router.get("/", response_model=list[MedicalStudySchema])
async def get_all_medical_studies_():
    """Get all medical studies"""
    return await get_all_medical_studies()


@router.put("/", response_model=MedicalStudySchema)
async def update_medical_study_(medical_study_update_schema: MedicalStudyUpdateSchema):
    """Update a medical study"""
    return await update_medical_study(medical_study_update_schema)


@router.delete("/{medical_study_id}", status_code=status.HTTP_204_NO_CONTENT)
async def delete_medical_study_(medical_study_id: int):
    """Delete a medical study"""
    await delete_medical_study(medical_study_id)
    return None
